﻿ function getdomain(){
  var arydomain = new Array(".com.cn",".net.cn",".org.cn",".gov.cn",".com",".cn",".net",".cc",".org",".info",".biz",".tv"); 
  var domain = document.domain; 
  var tmpdomain = ""; 
for(var i=0;i<arydomain.length; i++) 
  { 
  tmpdomain = arydomain[i]; 
  if(domain.indexOf(tmpdomain) != -1) 
  { 
  domain = domain.replace(tmpdomain,""); 
  domain = domain.substring(domain.lastIndexOf(".")+1,domain.length); 
domain = domain + tmpdomain; 
break; 
  } 
} 
return domain;
}
function GetCookie (name){
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
            return getCookieVal (j);

        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
function getCookieVal (offset){
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
        endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function SetCookie (name, value){
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;

    var expires = (argc > 2) ? getExpDate(argv[2],0,0) : null;
    var path = (argc > 3) ? argv[3] :"/";
    var domain = (argc > 4) ? argv[4] :getdomain();
    var secure = (argc > 5) ? argv[5] :false;
    
	//expires=getExpDate(365,0,0); if don't set time ,the browser is automatic close cookies.

     document.cookie = name + "=" + escape (value) +
     ((expires == null) ? "" : ("; expires=" + expires)) +
     ((path == null) ? "" : ("; path=" + path)) +
     ((domain == null) ? "" : ("; domain=" + domain)) +
     ((secure == true) ? "; secure" : "");
	 //alert(domain);
}


//expier time function
 function getExpDate(days, hours, minutes)
    {
        var expDate = new Date();
        if(typeof(days) == "number" && typeof(hours) == "number" && typeof(hours) == "number")
        {
            expDate.setDate(expDate.getDate() + parseInt(days));
            expDate.setHours(expDate.getHours() + parseInt(hours));
            expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
            return expDate.toGMTString();
        }
    }
	
//get ？parameters	such as ：Request("a")=1；
function Request(strName)
{
var strHref = window.location.href;
var intPos = strHref.indexOf("?"); //get ? position
var strRight = strHref.substr(intPos + 1);//get ? string at last

var arrTmp = strRight.split("&");
for(var i = 0; i < arrTmp.length; i++)
{
var arrTemp = arrTmp[i].split("=");
if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
}
return "";
}




//bao chi tupian bu bian xing
/*
tu pian de gao kuan fou ze wu xiao
width：
height：
str：tiao zheng tu pian id qing yong , ge kai
*/
function imgreload(width,height,str){
  var imgstr=str;
  var imgs=imgstr.split(",")
 for(var i=0;i<imgs.length-1;i++){
 window.setTimeout("doimgreload('"+imgs[i]+"',"+width+","+height+");",500)
 }
 } 
 function doimgreload(aa,w,h){
 var a=document.getElementById(aa);
 if(a!=null ||a!="null"){
  if(a.height==h){
	  if(a.width>w){
	   a.height=h*w/a.width;
	   a.width=w;
	  } 
  }else{
	  if(a.height>h){
	   a.width=h*w/a.height;
	   a.height=h;
	  }  
	  
	  }
 }
 }

